<extend name="Public:base" />
<!-- 网站标题 -->
<block name="title">角色管理页面</block>
<block name="appendheader">
	<!-- 删除确认插件 -->
	<script type="text/javascript" src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=default"></script>
	<script type="text/javascript" src="__PUBLIC__/artDialog/iframeTools.js"></script>
	<script type="text/javascript" src="__PUBLIC__/common/js/list.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#WebMenu-1000").addClass('active');	//选中父菜单
			$("#WebMenu-1006").addClass('active');	//选中当前菜单
			
			//特别注意：
			//在模态窗口中异步加载的内容只有第一次传递参数值是合适的，在不刷新页面的情况下以后的加载都直接从缓存中读取
			//为避免此类bug，在每次关闭模态窗口时在回调函数中刷新整个网页（songyb 2015-08-18）
			$('#set_role_page').on('hidden.bs.modal', function (e) {
				location.reload(true);
			});
			
			$('#set_action_page').on('hidden.bs.modal', function (e) {
				location.reload(true);
			})
			
		});
		
		//打开授权页面
		function set_role_page(name) {
			var strChecked = '';
			
			$("input[id='ids']").each(function() {
				if(this.checked==true){
					this.checked==false;
				}
			});
			
			//以下语句只适用于MAdmin框架，MAdmin框架中main.js的第387行
			$('.checkall').closest('table').find('input[type=checkbox]').iCheck('uncheck');
			$("input[name='"+name+"']").iCheck('check');
			
			strChecked = $("input[name='"+name+"']").val();
			$('#set_role_page').modal({
				remote:'__APP__?g=Admin&m=Role&a=select_page&roleid='+strChecked
			});
		}
		
		//授权页面全选和取消全选切换
		function set_check(obj) {
			if(obj.checked == true) {
				$(obj).siblings('ul').find("input[type='checkbox']").each(function() {
					this.checked = true;
				});
			} else {
				$(obj).siblings('ul').find("input[type='checkbox']").each(function() {
					this.checked = false;
				});
			}
		}
		
		//授权页面全选和取消全选切换
		function set_parent_check(obj) {
			if(obj.checked == true) {
				$(obj).siblings('ul').find("input[type='checkbox']").each(function() {
					this.checked = true;
				});
			} else {
				$(obj).siblings('ul').find("input[type='checkbox']").each(function() {
					this.checked = false;
				});
			}
		}
		
		//授权页面自动选中和取消选中父节点
		function set_parent_check(obj) {
			if(obj.checked == true) {
				$(obj).parent().parent().parent().siblings("input").each(function() {
					this.checked = true;
				});
			} else {
				//判断兄弟节点有没有选中
				var strFlag = false;
				$(obj).parent().parent().parent('ul').find("input[type='checkbox']").each(function() {
					if(this.checked == true) {
						strFlag = true;
					}
				});
				//若都没有选中，则让父节点也不选中
				if(strFlag == false) {
					$(obj).parent().parent().parent().siblings("input").each(function() {
						this.checked = false;
					});
				}
			}
		}
	</script>
	<!-- 授权页面样式 -->
	<style>
		ul.page-list li a { padding-left:20px; }
		ul.page-list ul { margin-left:25px; margin-top:5px; }
		ul.page-list ul li { line-height:24px; }
		ul.page-list .page_checkall { position:absolute; top:8px; left:5px; z-index:999; }
	</style>
</block>
<!-- 当前位置 -->
<block name="breadcrumb">
	<div class="page-header pull-left">
		<div class="page-title">角色管理</div>
	</div>
	<ol class="breadcrumb page-breadcrumb pull-left">
		<li><i class="fa fa-home"></i>&nbsp;<a href="__APP__?g=Admin">首页</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
		<li><a href="#">系统设置</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
		<li class="active">角色管理</li>
	</ol>
</block>
<!-- 网页主内容区 -->
<block name="main_content">
	<div class="row">
		<div class="col-md-12">
			<div class="portlet box">
				<div class="portlet-body">
					<div class="row mbm">
						<div class="col-md-4">
							<a href="__APP__?g=Admin&m=Role&a=add" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;添加</a>&nbsp;
							<a href="javascript:confirm_deleteall();" class="btn btn-danger"><i class="fa fa-trash-o"></i>&nbsp;批量删除</a>
						</div>
						<div class="col-md-4">
							<!-- 公用条件检索html（若特殊则需单独处理） -->
							<include file="Public:search" />
						</div>
					</div>
					<form id="myform" name="myform" action="__APP__?g=Admin&m=Role&a=delete" method="post" >
						<table class="table table-hover table-striped table-bordered table-advanced tablesorter tb-sticky-header">
							<thead>
								<tr>
									<th width="40">
										<input type="checkbox" class="checkall" />
									</th>
									<th>角色编号</th>
									<th>角色名称</th>
									<th>角色描述</th>
									<th width="50">状态</th>
									<th width="220">管理操作</th>
								</tr>
							</thead>
							<tbody>
								<volist name="data" id="vo">
		 							<tr>
										<td><input type="checkbox" id="ids" name="ids[{$i}]" value="{$vo.id}" /></td>
										<td>{$vo.id}</td>
										<td>{$vo.name}</td>
										<td>{$vo.intro}</td>
										<td>{$vo.status}</td>
										<td>
											<a type="button" href="javascript:set_role_page('ids[{$i}]');" class="btn btn-warning btn-xs mbs"><i class="fa fa-cog"></i>设置权限</a>&nbsp;
											<a type="button" href="__APP__?g=Admin&m=Role&a=edit&id={$vo.id}" class="btn btn-blue btn-xs mbs"><i class="fa fa-edit"></i>编辑</a>&nbsp;
											<a type="button" href="javascript:confirm_delete('ids[{$i}]')" class="btn btn-danger btn-xs mbs"><i class="fa fa-trash-o"></i>删除</a>
										</td>
									</tr>
								</volist>
							</tbody>
						</table>
					</form>
					<!-- 显示分页信息 -->
					{$show}
				</div>
			</div>
		</div>
	</div>
	<!-- 设置权限 -->
	<div style="display: display;" id="set_role_page" tabindex="-1" role="dialog" aria-labelledby="modal-responsive-label" aria-hidden="true" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content"></div>
		</div>
	</div>
</block>